class RelationshipObserver < ActiveRecord::Observer
  def after_create(relationship)
    msg = Message.new
    msg.sender_id = 0
    msg.receiver = relationship.neighbor
    msg.title = "#{relationship.user.login}刚刚加你为好友了"
    msg.content = "#{relationship.neighbor.login}，\r\n\r\n" + 
                  "#{relationship.user.login}刚刚加你为好友，去他/她的主页( http://www.1kg.org/users/#{relationship.user.id} )看看吧\r\n\r\n\r\n\r\n\r\n\r\n" +
                  "多背一公斤客服"
    msg.save!
  end
end
